package com.wuyou.controller;

import com.wuyou.domain.Result;
import com.wuyou.domain.bo.AdvPayLogBO;
import com.wuyou.dto.AdvPayLogDTO;
import com.wuyou.service.IAdvPayLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 刘雷雨
 * @since 2022-09-29
 */
@RestController
@RequestMapping("/advPayLog")
@Api(value = "广告支付订单接口")
public class AdvPayLogController {

    @Autowired
    private IAdvPayLogService advPayLogService;

    @PostMapping
    public Result findAdvInfoPayByOrderNum(@RequestParam String orderNum) {
        return Result.OK();
    }

    @ApiOperation(value = "根据订单号修改广告订单信息")
    @PostMapping("updateAdvPayInfoByOrderNum")
    public Result updateAdvPayInfoByOrderNum(@RequestBody AdvPayLogDTO advPayLogDTO) {
        try {
            //DTO转BO
            AdvPayLogBO advPayLogBO = new AdvPayLogBO();
            BeanUtils.copyProperties(advPayLogDTO,advPayLogBO);

            return Result.OK().setData(advPayLogService.updateAdvPayInfoByOrderNum(advPayLogBO));
        } catch (BeansException e) {
            e.printStackTrace();
            return Result.ERROR();
        }
    }
}
